



function getMenuComponentAndName(component) {
    let menuList = sessionStorage.getItem('menuList');
    if(menuList) {
        menuList = JSON.parse(menuList);
    }
    let mainMenu = '',subMenu = '', mainMenuName = '',subMenuName = '';
    let isFound = false;
    for (let i=0; i<menuList.length; i++) {
        let item = menuList[i],children = menuList[i].children;
        if(item.component === component) {
            mainMenu = item.component;
            mainMenuName = item.name;
            break;
        }
        if(children && children.length> 0) {
            for (let j=0;j<children.length;j++) {
                if(children[j].component === component) {
                    isFound = true;
                    mainMenu = item.component;
                    mainMenuName = item.name;
                    subMenu = children[j].component;
                    subMenuName = children[j].name;
                    break;
                }
            }
        }
        if(isFound) {
            break;
        }
    }
    return {mainMenu,subMenu, mainMenuName,subMenuName};
}

export {
    getMenuComponentAndName
}

